from rest_framework import serializers
from AppModel.models import *
from rest_framework.decorators import api_view


class UserInfoSerializer(serializers.ModelSerializer):

    class Meta:
        model = UserInfo
        #fields = ('nick_name','user_name','weixin_openid','phone_number')
        fields = ('user_name','weixin_openid','id_card','phone_number','company_name','labour_union','join_union','desc')


class UserSerializer(serializers.ModelSerializer):

    class Meta:
        model = UserInfo
        fields = ('weixin_id','phone_number')


class ActionInfoSerializer(serializers.ModelSerializer):

    class Meta:
        model = ActionInfo
        fields = ('action_name','start_time','end_time','testpaper','current_award_total','award_total_num','active_long','current_remind_num','choose_method','xcby','tsby','action_img','is_use','article_url')


class TestPaperInfoSerializer(serializers.ModelSerializer):

    class Meta:
        model = TestPaperInfo
        fields = ('title','starttime','endtime','examtime','pid')

class ExamScoreInfoSerializer(serializers.ModelSerializer):

    class Meta:
        model = ExamScore
        fields = ('user_name','company_name','score')

class QuestionBankSerializer(serializers.ModelSerializer):

    class Meta:
        model = QuestionBank
        fields = ('title','qtype','a','b','c','d','e','answer','score')

class AwardInfoSerializer(serializers.ModelSerializer):

    class Meta:
        model = AwardInfo
        fields = ('id','award_name','award_image','award_num')


class CompanyInfoSerializer(serializers.ModelSerializer):

    class Meta:
        model = CompanyInfo
        fields = ('id','company_name','company_address','company_connect','company_phone','company_desc')


class UserAwardInfoSerializer(serializers.ModelSerializer):

    class Meta:
        model = UserAward
        fields = ('user_name','phone_number','labour_name','company_name','company_address','is_finished','award_name','revice_time',"award_image")

class UserPrizeInfoSerializer(serializers.ModelSerializer):

    class Meta:
        model = UserPrizeInfo       
        fields = ('user_name','phone_number','labour_name','company_name','company_address','award_name','revice_time','is_prized','award_image')


class GlobalSettingsSerializer(serializers.ModelSerializer):

    class Meta:
        model = GlobalSettings
        fields = ('choose_method','xcby')
